package cn.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class UserValidatorInterceptor extends MethodFilterInterceptor {

	

	@Override
	protected String doIntercept(ActionInvocation arg0) throws Exception {
		System.out.println("------检查登陆验证------");
		
		Map session=ActionContext.getContext().getSession();
		//Map userinfo=arg0.getInvocationContext().getParameters();
		
		//String username=session.get("user.name").toString();

		//String[] loginUsername=(String[])parameters.get("user.name");
		//System.out.println("是否已有用户登陆"+session.get("loginUser"));
		if(session.get("loginUser")!=null){
			//return arg0.invoke();
			System.out.println("-----用户已登陆-----");
			return arg0.invoke();
		}else{
			System.out.println("-----用户未登录-----");
			return "fail";
		}
		
		
	}

}
